package com.lhy.admin.common.mvcplus.entity;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * ComparatorEnum 条件比较器枚举
 * @author hyluan
 * @date 2022/6/24 17:51
 */
public enum ComparatorEnum {
    NOT("not"),

    ILIKE("ilike"),

    LIKE("like"),

    lIKE_LEFT("like left"),

    lIKE_RIGHT("like right"),

    NOT_lIKE("not like"),

    EQ("eq"),

    NE("ne"),

    GE("ge"),

    LE("le"),

    GT("gt"),

    LT("lt"),

    IN("in"),

    NOT_IN("not in"),

    BETWEEN("between"),

    NOT_BETWEEN("not between"),

    IS_NULL("is null"),

    IS_NOT_NULL("is not null"),

    /**
     * json数组字段包含
     */
    JSON_ARRAY_CONTAINS("json_array_contains"),

    /**
     * json数组对象字段包含
     */
    JSON_OBJECT_CONTAINS("json_object_contains"),

    /**
     * json数组对象字段不包含
     */
    JSON_OBJECT_NOT_CONTAINS("json_object_not_contains"),

    /**
     * json对象相等提取
     */
    JSON_OBJECT_EQ("json_object_eq"),

    /**
     * json对象大于
     */
    JSON_OBJECT_GE("json_object_ge"),


    /**
     * json对象小于
     */
    JSON_OBJECT_LT("json_object_lt"),

    /**
     * json对象模糊匹配
     */
    JSON_OBJECT_LIKE("json_object_like"),


    /**
     * 字符串多条件匹配
     */
    FIND_IN_SET("find_in_set"),

    ORDER_BY("order by"),

    GROUP_BY("group by"),

    ;

    private String value;

    ComparatorEnum(String value) {
        this.value = value;
    }

    @Override
    @JsonValue
    public String toString() {
        return String.valueOf(value);
    }

    @JsonCreator
    public static ComparatorEnum fromValue(String text) {
        for (ComparatorEnum b : ComparatorEnum.values()) {
            if (String.valueOf(b.value).equals(text)) {
                return b;
            }
        }
        return null;
    }
}
